/*
 * FileName: 简历列表
 * Created Date: 2022-10-19 10:17:38
 * Author: 文初阳
 * -----
 * Last Modified: 2022-10-19 10:17:38
 * Modified By: 文初阳
 */

import { Button, Layout } from 'antd';
import React, { useContext, useEffect, useState } from 'react';
import { queryResumeListApi } from '../../apis/resume';
import { ResumeContext } from '../../states/resume';
import { IQueryResumeListResponse, IResumeListItem } from '../../types/resume';
import CardInfo from './card/CardInfo';
import styles from './List.module.scss';

const { Header, Content } = Layout;

const mockData = [
    {
        resumeName: '001',
        name: '文初阳',
        job: '前端开发工程师',
        updateTime: '2022/12/12',
    },
];

const List: React.FC = () => {
    const [resumeList, setResumeList] = useState<IResumeListItem[]>(mockData);
    const { setPageName } = useContext(ResumeContext);
    const handleAddClick = () => {
        setPageName('add');
    };

    useEffect(() => {
        // (async () => {
        //     const resumeListData = await queryResumeListApi();
        //     resumeListData.map((item: IQueryResumeListResponse) => ({
        //         resumeName: item.name,
        //         name: item.content.baseInfo?.[0]?.name || '',
        //         job: item.content.baseInfo?.[0]?.job || '',
        //         updateTime: item.updateTime,
        //     }));
        //     setResumeList([...resumeListData]);
        // })();
    }, []);
    return (
        <Layout>
            <Header className={styles.header}>
                <h1>简历列表</h1>
            </Header>
            <Content className={styles.content}>
                {resumeList.map((item: IResumeListItem) => (
                    <CardInfo data={item} />
                ))}
                <Button type="primary" onClick={handleAddClick}>
                    新增简历
                </Button>
            </Content>
        </Layout>
    );
};

export default List;
